<?php
namespace app\api\controller\com;
class Articlecat extends Base {
	//列表
	public function lists() {
		$d = $this->post;
		$rule = [
			'page' => 'require|integer',
			'limit' => 'require|integer',
		];
		$msg = [];
		check($rule, $msg, $d);

		$map = [];
		if ($d['parent_id'] != '') {
			$map[] = ['and', 'parent_id', '=', $d['parent_id']];
		}
		if ($d['keyword'] != '') {
			$map[] = ['and', 'title', 'like', "%{$d['keyword']}%"];
		}
		$w = where($map);
		$rs = $this->db->query("select * from article_cat $w[0] order by sort desc,id desc" . limit($d['page'], $d['limit']), $w[1]);
		if ($rs) {
			return suc($rs);
		}
		return suc([], 0);
	}
}
